package com.yvon.boot.common.validation.annotation;

import com.yvon.boot.common.validation.validator.EnumValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * 枚举值校验注解
 *
 * <p>
 *     用法：@Enumeration(value = SexEnums.class)<br>
 *         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 *         </span>private SexEnums sex; <br>
 * </p>
 *
 * @author : Yvon
 * @since : 2021-06-22
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
@Constraint(validatedBy = EnumValidator.class)
public @interface Enum {

    /**
     * 价值
     *
     * @return {@link Class<?> }
     * @author : Yvon / 2021-06-22
     */
    Class<? extends java.lang.Enum> value();

    /**
     * 消息
     *
     * @return {@link String }
     * @author : Yvon / 2021-06-22
     */
    String message() default "入参值不在正确枚举中!";

    /**
     * 组
     *
     * @return {@link Class<?>[] }
     * @author : Yvon / 2021-06-22
     */
    Class<?>[] groups() default {};

    /**
     * 获取枚举值的方法
     */
    String method() default "getCode";

    /**
     * 有效载荷
     *
     * @return {@link Class<? extends Payload>[] }
     * @author : Yvon / 2021-06-22
     */
    Class<? extends Payload>[] payload() default {};
}